/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
package com.stip.server.entities;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author BlueBerry
 */
@Entity
@Table(name = "users_info")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "UsersInfo.findAll", query = "SELECT u FROM UsersInfo u"),
    @NamedQuery(name = "UsersInfo.findByUid", query = "SELECT u FROM UsersInfo u WHERE u.uid = :uid"),
    @NamedQuery(name = "UsersInfo.findByEmail", query = "SELECT u FROM UsersInfo u WHERE u.email = :email"),
    @NamedQuery(name = "UsersInfo.findByQq", query = "SELECT u FROM UsersInfo u WHERE u.qq = :qq"),
    @NamedQuery(name = "UsersInfo.findByPhone", query = "SELECT u FROM UsersInfo u WHERE u.phone = :phone"),
    @NamedQuery(name = "UsersInfo.findByAbstracts", query = "SELECT u FROM UsersInfo u WHERE u.abstracts = :abstracts")})
public class UsersInfo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 15)
    @Column(name = "uid")
    private String uid;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="电子邮件无效")//if the field contains email address consider using this annotation to enforce field validation
    @Size(max = 50)
    @Column(name = "email")
    private String email;
    @Size(max = 50)
    @Column(name = "qq")
    private String qq;
    // @Pattern(regexp="^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", message="电话/传真格式无效，应为 xxx-xxx-xxxx")//if the field contains phone or fax number consider using this annotation to enforce field validation
    @Size(max = 20)
    @Column(name = "phone")
    private String phone;
    @Size(max = 200)
    @Column(name = "abstracts")
    private String abstracts;
    @JoinColumn(name = "uid", referencedColumnName = "uid", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private UsersMain usersMain;
    @JoinColumn(name = "dorm", referencedColumnName = "id")
    @ManyToOne
    private Dorm dorm;

    public UsersInfo() {
    }

    public UsersInfo(String uid) {
        this.uid = uid;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getQq() {
        return qq;
    }

    public void setQq(String qq) {
        this.qq = qq;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getAbstracts() {
        return abstracts;
    }

    public void setAbstracts(String abstracts) {
        this.abstracts = abstracts;
    }

    public UsersMain getUsersMain() {
        return usersMain;
    }

    public void setUsersMain(UsersMain usersMain) {
        this.usersMain = usersMain;
    }

    public Dorm getDorm() {
        return dorm;
    }

    public void setDorm(Dorm dorm) {
        this.dorm = dorm;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (uid != null ? uid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UsersInfo)) {
            return false;
        }
        UsersInfo other = (UsersInfo) object;
        if ((this.uid == null && other.uid != null) || (this.uid != null && !this.uid.equals(other.uid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.stip.server.entities.UsersInfo[ uid=" + uid + " ]";
    }
    
}
